#pragma once

#include "base_types.h"
#include <vector>
#include <memory>

// Base packet class
class CCPacketBase {
public:
    CCPacketBase() = default;
    virtual ~CCPacketBase() = default;
    
    // Get packet data
    virtual const char* GetData() const = 0;
    virtual size_t GetSize() const = 0;
    
    // Set packet data
    virtual void SetData(const char* data, size_t size) = 0;
    
    // Clear packet
    virtual void Clear() = 0;
    
    // Clone packet
    virtual std::unique_ptr<CCPacketBase> Clone() const = 0;
};

// Simple packet implementation
class CSimplePacket : public CCPacketBase {
public:
    CSimplePacket() = default;
    explicit CSimplePacket(size_t initial_size = 0);
    CSimplePacket(const char* data, size_t size);
    virtual ~CSimplePacket() = default;
    
    // Implement CCPacketBase interface
    const char* GetData() const override { return data.empty() ? nullptr : data.data(); }
    size_t GetSize() const override { return data.size(); }
    void SetData(const char* data, size_t size) override;
    void Clear() override { data.clear(); }
    std::unique_ptr<CCPacketBase> Clone() const override;
    
    // Additional methods
    void Append(const char* data, size_t size);
    void Resize(size_t new_size);
    char* GetBuffer() { return data.data(); }
    const char* GetBuffer() const { return data.data(); }
    
private:
    std::vector<char> data;
};

// Wspack implementation (simplified)
class CWspack {
public:
    CWspack() = default;
    ~CWspack() = default;
    
    // Pack data
    int Pack(const char* data, size_t size);
    
    // Unpack data
    int Unpack(const char* data, size_t size);
    
    // Get packed data
    const char* GetData() const { return buffer.data(); }
    size_t GetSize() const { return buffer.size(); }
    
    // Clear
    void Clear() { buffer.clear(); }
    
private:
    std::vector<char> buffer;
};